home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / VertexAG.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-01  |  5.3 KB  |  164 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include "FuncEnum.h"
  42. #ifdef WIN32
  43. #include <windows.h>
  44. #endif
  45. #include <GL/gl.h>
  46. #include <malloc.h>
  47.  
  48. /* This will be set by compile time #defines                     */
  49. /* They control the size and functionality of the code generated */
  50. #ifdef FULL_FUNCPTR_PATHS
  51. #define FUNC_PTRS 1
  52. #else
  53. #define FUNC_PTRS 0
  54. #endif
  55.  
  56. char* pntSuccinct[] = {
  57.     "",
  58.     "Ptr"
  59. };
  60.  
  61. char* colorSuccinct[] = {
  62.     "",
  63.     "Color"
  64. };
  65.  
  66. char* indexSuccinct[] = {
  67.     "",
  68.     "Index"
  69. };
  70.  
  71. char* normalSuccinct[] = {
  72.     "",
  73.     "Norm"
  74. };
  75.  
  76. char* textureSuccinct[] = {
  77.     "",
  78.     "Tex"
  79. };
  80.  
  81. char* PrintEntry(FILE *fp, int p, int cd, int id, int nd, int td)
  82. {
  83.     char* funcName = (char*)malloc(64);
  84.     sprintf(funcName,"VertArr%s%s%s%s%s",
  85.         pntSuccinct[p], 
  86.         colorSuccinct[cd], 
  87.         indexSuccinct[id], 
  88.         normalSuccinct[nd], 
  89.         textureSuccinct[td]
  90.         );
  91.     fprintf(fp,"#define FUNCTION %s\n", funcName);
  92.     if (p)
  93.         fprintf(fp,"#define FUNCTION_PTRS\n");
  94.     if (cd)
  95.         fprintf(fp,"#define COLOR_DATA\n");
  96.     if (id)
  97.         fprintf(fp,"#define INDEX_DATA\n");
  98.     if (nd)
  99.         fprintf(fp,"#define NORMAL_DATA\n");
  100.     if (td)
  101.         fprintf(fp,"#define TEXTURE_DATA\n");
  102.     fprintf(fp,"#include \"VertexAX.c\"\n");
  103.     fprintf(fp,"#undef FUNCTION\n");
  104.     fprintf(fp,"#undef TEXTURE_DATA\n");
  105.     fprintf(fp,"#undef NORMAL_DATA\n");
  106.     fprintf(fp,"#undef INDEX_DATA\n");
  107.     fprintf(fp,"#undef COLOR_DATA\n");
  108.     fprintf(fp,"#undef FUNCTION_PTRS\n");
  109.     fprintf(fp,"\n");
  110.     return funcName;
  111. }
  112.  
  113. #define TOTAL_FUNCS 2*2*2*2*2
  114.  
  115. main()
  116. {
  117.     VertexArrayFunc function;
  118.     int i;
  119.     int p, cd, id, nd, td;
  120.     FILE *fp, *header;
  121.     char* names[TOTAL_FUNCS];
  122.  
  123.     for (i=0; i<TOTAL_FUNCS; i++)
  124.         names[i] = "Noop";
  125.     header = fopen("VertexAX.h", "w");
  126.     fprintf(header, "/*\n * File VertexAX.h generated from VertexAG (source file VertexAG.c)\n */\n\n");
  127.     fp = fopen("VertexAF.c", "w");
  128.     fprintf(fp, "/*\n * File VertexAF.c generated from VertexAG (source file VertexAG.c)\n */\n\n");
  129.     fprintf(fp, "#include \"Vertex.h\"\n");
  130. #ifdef GL_EXT_vertex_array
  131. #ifndef WIN32 /* The Microsoft header lies! */
  132.     for (p=0;p<=FUNC_PTRS;p++) {
  133.         for (cd=0;cd<2;cd++) {
  134.             for (id=0;id<2;id++) {
  135.                 for (nd=0;nd<2;nd++) {
  136.                     for (td=0;td<2;td++) {
  137.                         if (!(cd && id || td && id)) {
  138.                             function.word = 0;
  139.                             function.bits.functionPtrs  = p;
  140.                             function.bits.colorData    = cd;
  141.                             function.bits.indexData    = id;
  142.                             function.bits.normalData    = nd;
  143.                             function.bits.textureData    = td;
  144.                             names[function.word] = PrintEntry(fp, p, cd, id, nd, td);
  145.                             fprintf(header, "void %s(TestPtr);\n", names[function.word]);
  146.                         }
  147.                     }
  148.                 }
  149.             }
  150.         }
  151.     }
  152. #endif /* WIN32 */
  153. #endif
  154.     fclose(fp);
  155.     fprintf(header, "void Noop(TestPtr);\n");
  156.     fprintf(header, "typedef void (*VertexArrayExecuteFunc)(TestPtr);\n");
  157.     fprintf(header, "\nVertexArrayExecuteFunc VertexArrayExecuteTable[] = {\n");
  158.     for (i=0; i<TOTAL_FUNCS; i++)
  159.         fprintf(header, "    %s,\n", names[i]);
  160.     fprintf(header, "};\n");
  161.     fclose(header);
  162.     return 0;
  163. }
  164.